<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');


/**
* 返回magento数据
*/
class Magentoreturn
{
	
	function __construct()
	{
		$this->CI =& get_instance();
		   $this->db1 = $this->CI->load->database('default', TRUE);
	}


public function returne(){
$row = $this->db1->get_where("d_shop","platfromname='Magento'")->result_array();

foreach ($row as $v) {
if ($v['amazonkey']=='') continue;

	$shopname=$v['name'];
	$datax=json_decode($v['amazonkey'],true);
    $platfrom=$datax['magentotoken'];

$listrow = $this->db1->get_where("db_order_list","shopname='{$shopname}' and is_update_platform='0' and (order_status='4' or order_status='5')")->result_array();

foreach ($listrow as $value) {
$order_id=$value['order_id'];
$shipping_id=$value['shipping_id'];
$tradeid=$value['tradeid'];
$shippingrow=$this->db1->get_where("db_order_express","id='{$shipping_id}'")->result_array();
foreach ($shippingrow as $sv) {
	$shipping_name=$sv['magento_express'];
}
 

//$shipping_name=$value['shipping_name'];
$shipping_number=$value['shipping_number'];

$url="https://network.pokemoncos.com/data/erptoorder.php?tradeid={$tradeid}&shipping_name={$shipping_name}&shipping_number={$shipping_number}&platfrom={$platfrom}";
echo $url;
file_get_contents($url);

$this->db1->update("db_order_list",array("is_update_platform"=>'1'),"order_id=".$order_id);
$log='';
$log['orderId']=$order_id;
$log['updateTime']=date('Y-m-d H:i:s');
$log['shippingName']=$shipping_name;
$log['shippingNumber']=$shipping_number;
$log['types']='magento';
$log['content']='自动同步物流信息';
$this->db1->insert("db_onlineshop_log",$log);

}
}
}






}















?>